package com.corona.game;

import com.badlogic.gdx.audio.Music;
import com.corona.Game;

import java.util.ArrayList;

/* compiled from: Battle.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/BattleFadeOutMusic.class */
class BattleFadeOutMusic extends Action {
    Float frame;
    float originalVolume;
    Music music;
    String timeOfDay;
    public static boolean playerFainted = false;
    public static boolean stop = false;
    public Action.Layer layer = Action.Layer.gui_129;
    ArrayList<Float> frames = new ArrayList<>();

    public BattleFadeOutMusic(Game game, Action nextAction) {
        super(new Object[0]);
        this.nextAction = nextAction;
        for (int i = 0; i < 14; i++) {
            this.frames.add(Float.valueOf(0.3f));
        }
        for (int i2 = 0; i2 < 14; i2++) {
            this.frames.add(Float.valueOf(0.25f));
        }
        for (int i3 = 0; i3 < 14; i3++) {
            this.frames.add(Float.valueOf(0.2f));
        }
        for (int i4 = 0; i4 < 14; i4++) {
            this.frames.add(Float.valueOf(0.15f));
        }
        for (int i5 = 0; i5 < 14; i5++) {
            this.frames.add(Float.valueOf(0.1f));
        }
        for (int i6 = 0; i6 < 7; i6++) {
            this.frames.add(Float.valueOf(0.05f));
        }
        for (int i7 = 0; i7 < 7; i7++) {
            this.frames.add(Float.valueOf(0.025f));
        }
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void firstStep(Game game) {
        this.music = game.currMusic;
        this.timeOfDay = game.map.timeOfDay;
        game.musicController.battleFadeOut = true;
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (this.frames.isEmpty()) {
            game.musicController.inBattle = false;
            game.actionStack.remove(this);
            game.insertAction(this.nextAction);
            return;
        }
        this.frame = this.frames.get(0);
        this.frames.remove(0);
    }

    public void oldStep(Game game) {
        if (!game.map.timeOfDay.equals("night") || playerFainted) {
            if (this.firstStep) {
                this.originalVolume = game.currMusic.getVolume();
                this.music = game.currMusic;
                stop = false;
                this.firstStep = false;
            }
            if (this.frames.isEmpty() || stop) {
                game.insertAction(this.nextAction);
                game.actionStack.remove(this);
                if (!stop) {
                    this.music.stop();
                }
                this.music.setVolume(this.originalVolume);
                if (game.battle.drawAction == null && !playerFainted) {
                    game.currMusic = game.map.currRoute.music;
                    game.currMusic.play();
                }
                playerFainted = false;
                stop = false;
                return;
            }
            this.frame = this.frames.get(0);
            this.music.setVolume(this.frame.floatValue());
            this.frames.remove(0);
            return;
        }
        game.actionStack.remove(this);
        game.insertAction(this.nextAction);
    }
}
